/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jaiz.app.controller.db;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author chuy
 */
public class PersistenceHelper {
    private static final EntityManagerFactory emf;
    private static final EntityManager entityManager;
    static {
        try {
            emf = Persistence.createEntityManagerFactory("PersistenceMaps");
            entityManager = emf.createEntityManager();
            // Create the SessionFactory from standard (hibernate.cfg.xml) 
            // config file.
            //sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            // Log the exception. 
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }        
    }
    
    
    public static EntityManager getEntityManager() {
        return entityManager;
    }
}
